package cn.jit.util;

public class ResponseObject {
	public static final int SUCCESS_CODE = 200;
	public static final String SUCCESS_MSG = "请求成功！";
	public static final int SERVER_ERROR_CODE = 500;
	public static final String SERVER_ERROR_MSG = "服务内部错误！";
	
	private Integer code; // 状态码
	private Boolean isSuccess; // 是否成功
	private String msg; // 返回的信息描述
	private Object data; // 返回的数据

	public ResponseObject() {

	}
	
	/**
	 * 成功时的构造器
	 * @param code
	 * @param isSuccess
	 * @param data
	 */
	public ResponseObject(Integer code, Boolean isSuccess, Object data) {
		this.code = code;
		this.isSuccess = isSuccess;
		this.data = data;
	}
	
	/**
	 * 成功时的构造器
	 * @param code
	 * @param isSuccess
	 * @param data
	 */
	public ResponseObject(Object data) {
		this.code = 200;
		this.isSuccess = true;
		this.data = data;
	}
	
	/**
	 * 失败时的构造器
	 * @param code
	 * @param isSuccess
	 * @param msg
	 */
	public ResponseObject(Integer code, Boolean isSuccess, String msg) {
		this.code = code;
		this.isSuccess = isSuccess;
		this.msg = msg;
	}
	
	/**
	 * 失败时的构造器
	 * @param code
	 * @param isSuccess
	 * @param msg
	 */
	public ResponseObject(String msg) {
		this.code = 200;
		this.isSuccess = false;
		this.msg = msg;
	}
	

	public ResponseObject(Integer code, Boolean isSuccess, String msg, Object data) {
		this.code = code;
		this.isSuccess = isSuccess;
		this.msg = msg;
		this.data = data;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}
	
	public Boolean getIsSuccess() {
		return isSuccess;
	}

	public void setIsSuccess(Boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "ResponseObject [code=" + code + ", msg=" + msg + ", data=" + data + "]";
	}

}
